-- PostIt, the original version of this button was written
-- by Mark Igra, 1588 Henry St. #2. Berkeley, CA 94709.
-- Copyright Mark Igra.
-- Hybrid, "Exbando" by Peter Martori, 605 W. Montebello, Phx, AZ 85013
--
-- This button creates a note that you can name, hide, move & delete.
-- The note consists of a text field and a button which hides
-- the field if it is visible and shows it if it is not.
-- You create the note by clicking this button, naming the note, then
-- clicking where you want the note to be located.
-- You can move the note by double-clicking and dragging the note to
-- where you want it (keep the mouse button down on the second click).
-- You can remove the note by option-clicking it (hold the optionKey
-- down, then click the note field).
--
-- Feel free to place this button or a variant on all stacks. Please
-- include notice (first 4 lines).
global noteName
on mouseUp
global noteName
ask "Name the Note..."
if it is empty then exit mouseUp
put it into noteName
put the number of card fields + 1 into fieldNum
put the userLevel into saveLevel
set the userLevel to 5
if the userLevel < 5 then
answer "Can't make new fields now" with "OK"
exit mouseUp
end if
-- You will probably want to take this notice out
answer "Click where you want the note" with "Cancel" or "OK"
if it is "Cancel" then exit mouseUp
wait until the mouseClick
put the mouseLoc into noteLoc
set the cursor to 4 -- watch
set lockScreen to true
-- Create the field
put (return & "on openfield" & return & " get the short name of target" & return & " put it into noteName" & return & " if the optionKey is down then" & return & " set lockscreen to true" & return & " choose button tool" & return & " get loc of target" & return & " subtract 92 from item 2 of it" & return & " click at it" & return & " domenu" & quote & "Clear Button" & quote & return & " choose field tool" & return & " get loc of target" & return & " click at it" & return & " domenu" & quote & "Clear Field" & quote & return & " choose browse tool" & return & " set lockscreen to false" & return & " end if" & return && "wait 10 ticks" & return & " if the mouse is down then" & return & " repeat until the mouse is up" & return & " set the loc of the target to the mouseLoc" & return & " get the loc of target" & return & " subtract 92 from item 2 of it" & return & " set the loc of button notename to it" & return & " end repeat" & return & " end if" & return & "end openfield") into fieldscript
choose field tool
drag from noteLoc to item 1 of noteLoc + 150,item 2 of noteLoc + 200 with commandKey
set the style of card field fieldNum to rectangle
put the id of card field fieldNum into fieldID
set the name of card field fieldNum to notename
set the script of card field fieldNum to fieldscript
-- Make the button
makeButton noteLoc,fieldID
-- Return everything to normal.
choose browse tool
set the userLevel to saveLevel
set the cursor to saveCursor
set lockScreen to false
end mouseUp
on makeButton noteLoc,fieldID
global notename
put the number of buttons + 1 into buttonNum
choose button tool
drag from noteLoc to item 1 of noteLoc + 150,item 2 of noteLoc + 15 with commandKey
set the style of button buttonNum to rectangle
set the textfont of button buttonNum to geneva
set the textsize of button buttonNum to 9
set name of button buttonNum to notename
set the showname of button buttonNum to true
set the script of button buttonNum to PostItScript(fieldID)
end makeButton
-- The buttons that hide and show a post it note have a script
-- which is customized for the note they show. The button's script
-- uses the id of the field so that it will work no matter how the
-- fields are shuffled.
function PostItScript fieldID
return "on mouseUp" & return¬ -- Note the use of 'return' as end of line
&& "Set the visible of card field id" && fieldID && "to not the visible of card field id" && fieldID & return & "end mouseUp"
end PostItScript
-- part 2 (button)
-- low flags: 00
-- high flags: 0000
-- rect: left=307 top=199 right=239 bottom=345
-- title width / last selected line: 0
-- icon id / first selected line: 27354 / 27354
-- text alignment: 1
-- font id: 20
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Exbando
----- HyperTalk script -----
-- PostIt, the original version of this button was written
-- by Mark Igra, 1588 Henry St. #2. Berkeley, CA 94709.
-- Copyright Mark Igra.
-- Hybrid, "Exbando" by Peter Martori, 605 W. Montebello, Phx, AZ 85013
--
-- This button creates a note that you can name, hide, move & delete.
-- The note consists of a text field and a button which hides
-- the field if it is visible and shows it if it is not.
-- You create the note by clicking this button, naming the note, then
-- clicking where you want the note to be located.
-- You can move the note by double-clicking and dragging the note to
-- where you want it (keep the mouse button down on the second click).
-- You can remove the note by option-clicking it (hold the optionKey
-- down, then click the note field).
--
-- Feel free to place this button or a variant on all stacks. Please
-- include notice (first 4 lines).
global noteName
on mouseUp
global noteName
put the number of card fields + 1 into fieldNum
put "Tom" & fieldNum into notename
put the userLevel into saveLevel
set the userLevel to 5
if the userLevel < 5 then
answer "Can't make new fields now" with "OK"
exit mouseUp
end if
-- You will probably want to take this notice out
answer "Click where you want the note" with "Cancel" or "OK"
if it is "Cancel" then exit mouseUp
wait until the mouseClick
put the mouseLoc into noteLoc
set the cursor to 4 -- watch
set lockScreen to true
-- Create the field
put (return & "on openfield" & return & " if the optionKey is down then" & return & " set lockscreen to true" & return & " choose button tool" & return & " get loc of target" & return & " subtract 72 from item 2 of it" & return & " subtract 72 from item 1 of it" & return & " click at it" & return & " domenu" && quote & "Clear Button" & quote & return & " choose field tool" & return & " get loc of target" & return & " click at it" & return & " domenu" && quote & "Clear Field" & quote & return & " choose browse tool" & return & " set lockscreen to false" & return & " end if" & return && "wait 10 ticks" & return & " if the mouse is down then" & return & " repeat until the mouse is up" & return & " set the loc of the target to the mouseLoc" & return & " get the loc of target" & return & " subtract 72 from item 2 of it" & return & " subtract 72 from item 1 of it" & return & " set the loc of button" && notename && "to it" & return & " end repeat" & return & " end if" & return & "end openfield") into fieldscript
choose field tool
drag from noteLoc to item 1 of noteLoc + 150,item 2 of noteLoc + 150 with commandKey
set the style of card field fieldNum to rectangle
set the name of card field fieldNum to notename
set the script of card field fieldNum to fieldscript
put the id of card field fieldNum into fieldID
-- Make the button
makeButton noteLoc,fieldID
-- Return everything to normal.
choose browse tool
set the userLevel to saveLevel
set the cursor to saveCursor
set lockScreen to false
end mouseUp
on makeButton noteLoc,fieldID
global notename
put the number of buttons + 1 into buttonNum
choose button tool
drag from noteLoc to item 1 of noteLoc + 15,item 2 of noteLoc + 15 with commandKey
set the style of button buttonNum to rectangle
set the script of button buttonNum to PostItScript(fieldID)
set the name of button buttonNum to notename
set the rect of button buttonNum to item 1 of noteLoc, item 2 of noteLoc, item 1 of noteLoc + 6, item 2 of noteLoc + 6
end makeButton
-- The buttons that hide and show a post it note have a script
-- which is customized for the note they show. The button's script
-- uses the id of the field so that it will work no matter how the
-- fields are shuffled.
function PostItScript fieldID
return "on mouseUp" & return¬ -- Note the use of 'return' as end of line
&& "Set the visible of card field id" && fieldID && "to not the visible of card field id" && fieldID & return & "end mouseUp"
end PostItScript
-- part 3 (field)
-- low flags: 80
-- high flags: 0002
-- rect: left=323 top=127 right=328 bottom=474
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: A cautionary note...
----- HyperTalk script -----
on openfield
get the short name of target
put it into noteName
if the optionKey is down then
set lockscreen to true
choose button tool
get loc of target
subtract 92 from item 2 of it
click at it
domenu"Clear Button"
choose field tool
get loc of target
click at it
domenu"Clear Field"
choose browse tool
set lockscreen to false
end if
wait 10 ticks
if the mouse is down then
repeat until the mouse is up
set the loc of the target to the mouseLoc
get the loc of target
subtract 92 from item 2 of it
set the loc of button notename to it
end repeat
end if
end openfield
-- part 4 (button)
-- low flags: 00
-- high flags: 8002
-- rect: left=323 top=127 right=143 bottom=474
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: A cautionary note...
----- HyperTalk script -----
on mouseUp
Set the visible of card field id 3 to not the visible of card field id 3
end mouseUp
-- part 7 (field)
-- low flags: 80
-- high flags: 0002
-- rect: left=144 top=198 right=349 bottom=295
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Tom2
----- HyperTalk script -----
on openfield
if the optionKey is down then
set lockscreen to true
choose button tool
get loc of target
subtract 72 from item 2 of it
subtract 72 from item 1 of it
click at it
domenu "Clear Button"
choose field tool
get loc of target
click at it
domenu "Clear Field"
choose browse tool
set lockscreen to false
end if
wait 10 ticks
if the mouse is down then
repeat until the mouse is up
set the loc of the target to the mouseLoc
get the loc of target
subtract 72 from item 2 of it
subtract 72 from item 1 of it
set the loc of button Tom2 to it
end repeat
end if
end openfield
-- part 8 (button)
-- low flags: 00
-- high flags: 0002
-- rect: left=144 top=198 right=204 bottom=150
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Tom2
----- HyperTalk script -----
on mouseUp
Set the visible of card field id 7 to not the visible of card field id 7
end mouseUp
-- part contents for background part 1
----- text -----
Flush with success I decided to revisit my earlier attemp and improve upon it. Just for the hell of it!
"Expando II" allows you to name the note. Expand and collapse it. Move it around and delete it.
"Expando III" is the same as "II", but doesn't get a name and has a little button like "Post-its". If you have ever put a "Post-it" in some text and then gone back and edited, you will appreciate Expando III.
I have had fun playing with these
different ideas. My scripting is artless. I would love to hear from someone who knows what they are doing. A brutal critique would be well taken.
-- part contents for card part 3
----- text -----
If you let part of a note disappear off the card, it won't be able to find the button when you try to delete it.
Just "cancel", move the note out into the open and then blow it away.
-- part contents for card part 7
----- text -----
what is this stupid button doing here. Double-click the note, keep the mouse button down on the second click and put this somewhere out of the way.